<template>
    <LoginHeader>欢迎登录</LoginHeader>
    <section class="login-section">
        <div class="wrapper">
            <nav>
                <a @click="activeName = 'account'" :class="{active:activeName==='account'}" href="javascript:;">账户登录</a>
                <a @click="activeName = 'qrcode'" :class="{ active: activeName === 'qrcode' }" href="javascript:;">扫码登录</a>
            </nav>
            <!-- 表单 -->
            <LoginForm v-if="activeName === 'account'">表单</LoginForm>
            <!-- 二维码 -->
            <div v-if="activeName === 'qrcode'" class="qrcode-box">
                <img src="@/assets/images/qr.jpg" alt="">
                <p>打开 <a href="javascript:;">小兔鲜App</a> 扫码登录</p>
            </div>
        </div>
    </section>
    <LoginFooter />
</template>
  
<script>
import {ref} from 'vue'
import LoginHeader from './components/login-header'
import LoginFooter from './components/login-footer'
import LoginForm from './components/login-form.vue'
import { useStore } from 'vuex'
import { useRoute } from 'vue-router'
export default {
    name: 'Login',
    components: {
        LoginHeader,
        LoginFooter,
        LoginForm
    },
    setup() {
        const activeName = ref('account')
        const route = useRoute()
        const store = useStore()
        
        //存储跳转路径
        // store.commit('user/setRedirectiveUrl',route.fullPath)
        return { activeName }
    }
}
</script>
  
<style scoped lang='less'>
.qrcode-box {
    text-align: center;
    img{
    transform: scale(0.5);
    }
    p {
        a {
            color: @xtxColor;
            font-size: 16px;
        }
    }
}

.login-section {
    height: 488px;
    background: linear-gradient(to right,@xtxColor,#fff);
    position: relative;

    .wrapper {
        width: 380px;
        background: #fff;
        min-height: 400px;
        position: absolute;
        left: 50%;
        top: 54px;
        transform: translate3d(100px, 0, 0);
        box-shadow: 0 0 10px rgba(0, 0, 0, .15);

        nav {
            height: 55px;
            border-bottom: 1px solid #f5f5f5;
            display: flex;
            padding: 0 40px;
            text-align: right;
            align-items: center;

            a {
                flex: 1;
                line-height: 1;
                display: inline-block;
                font-size: 18px;
                position: relative;

                &:first-child {
                    border-right: 1px solid #f5f5f5;
                    text-align: left;
                }

                &.active {
                    color: @xtxColor;
                    font-weight: bold;
                }
            }
        }
    }
}
</style>